package org.dbwebx.flex.delegate.impl {

	import mx.rpc.events.ResultEvent;
	import org.dbwebx.domain.User;
	import org.dbwebx.flex.delegate.impl.base.UserServiceBase;
	import org.swizframework.Swiz;
	import org.dbwebx.flex.common.event.UserEvent;

	[Bindable]
    public class UserService extends UserServiceBase {

		public function UserService()
		{
			super();
		}
		
		/**
		 * Dispatches event that user was loaded. 
		 * @param result the remote invocation result
		 */
		override protected function loadSuccessHandler(result:ResultEvent, ... args:Array):void
		{
			if(null != result){
				var user:User = User(result.result);
				var evt:UserEvent = null;
				if(null != args && args[0] is String){
					evt = new UserEvent(args[0]);
				}
				if(null==evt){
					evt = new UserEvent(UserEvent.U_LOADED_EVT);
				}
				evt.user = user;
				Swiz.dispatchEvent(evt);
			}
		}

    }
}